<form id="dictForm" class="form-horizontal" action="${ctx}/system/saveDict.do"  method="post">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h5 class="blue">编辑数据字典</h5>
    </div>
    <input type="hidden" name="id" id="id" class="col-xs-12 col-sm-4 required" value="${dictId!}"/>
    <div class="modal-body">
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="groupValue">字典组名称:</label>
            <div class="col-xs-12 col-sm-9">
                <div class="clearfix">
                    <input type="text" name="groupValue" id="groupValue" class="col-xs-12 col-sm-4 required" value="${dict.groupValue!}"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="code">字典代码:</label>
            <div class="col-xs-12 col-sm-9">
                <div class="clearfix">
                    <input type="text" name="code" id="code" class="col-xs-12 col-sm-4 required" value="${dict.code!}"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="name">字典名称:</label>
            <div class="col-xs-12 col-sm-9">
                <div class="clearfix">
                    <input type="text" name="name" id="name" class="col-xs-12 col-sm-4 required" value="${dict.name!}"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="sort">排序:</label>
            <div class="col-xs-12 col-sm-9">
                <div class="clearfix">
                    <input type="text" name="sort" id="sort" class="col-xs-12 col-sm-4 required" value="${dict.sort!}"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-3 no-padding-right">状态:</label>
            <div class="col-xs-12 col-sm-9">
                <div class="clearfix">
                    <label class="radio-inline blue"><input id="enable-0" name="enable" value="0" type="radio" class="ace" <#if !dict.enable?? || (dict.enable?? && dict.enable = 0)>checked="checked"</#if>/><span class="lbl">启用</span></label>
                    <label class="radio-inline blue"><input id="enable-1" name="enable" value="1" type="radio" class="ace" <#if !dict.enable?? || (dict.enable?? && dict.enable = 1)>checked="checked"</#if>/><span class="lbl">禁用</span></label>
                </div>
            </div>
        </div>

    </div>

    <div class="modal-footer center">
        <button type="submit" class="btn btn-sm btn-success"><i class="ace-icon fa fa-check"></i> 保存</button>
        <button type="button" class="btn btn-sm" data-dismiss="modal"><i class="ace-icon fa fa-times"></i> 取消</button>
    </div>
</form>
<script src="${ctx}/static/admin/assets/js/jquery.validate.js"></script>
<script src="${ctx}/static/admin/assets/js/jquery.validate.messages_zh.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".date-picker").datepicker({
            language : 'zh-CN',
            autoclose: true,
            todayHighlight: true
        });

        $("#dictForm").validate({
            errorElement: 'div',
            errorClass: 'help-block',
            focusInvalid: true,
            highlight: function (e) {
                $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
            },
            success: function (e) {
                $(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
                $(e).remove();
            },
            errorPlacement: function (error, element) {
                if(element.is('input[type=checkbox]') || element.is('input[type=radio]')) {
                    var controls = element.closest('div[class*="col-"]');
                    if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
                    else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
                }
                else if(element.is('.select2')) {
                    error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                }
                else if(element.is('.chosen-select')) {
                    error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
                }
                else error.insertAfter(element.parent());
            },

            submitHandler: function (form) {
               form.submit();
            },
            invalidHandler: function (form) {
            }
        })
    });
</script>